#!/bin/bash

source ./fuck-schoolnet.conf

# set ip address
ip addr add $wan_ip_addr/$wan_subnetmask dev $wan_device
ip addr add $lan_ip_addr/$lan_subnetmask dev $lan_device
ip link set dev $wan_device up
ip link set dev $lan_device up

# 开启路由转发
echo "1" > /proc/sys/net/ipv4/ip_forward

# 加载gre模块
modprobe ip_gre
# 配置gre隧道
ip tunnel add $gre_tunnel mode gre local $gre_local remote $gre_remote ttl 255
ip addr add $gre_address dev tunnel1 peer $gre_peer
ip link set dev $gre_tunnel up

# set route
ip route add $gre_remote via $wan_gateway
ip route add default via $gre_peer
